import {
	html2json,
	json2html
} from 'html2json'
	import {
		nanoid
	} from "nanoid"
	const md5 = require('js-md5')
export default{
	getJson() {
	let html = '<title title="文本 Text">'
	html +=
		'<u-text text="我用十年青春,赴你最后之约"></u-text>'
	html += '<u-text type="primary" text="主色"></u-text>'
	html += '<u-text type="error"   text="错误"></u-text>'
	html += '<u-text type="success" text="成功"></u-text>'
	html += '<u-text type="warning" text="警告"></u-text>'
	html += '<u-text type="info"    text="信息"></u-text>'
    html += '<u-text mode="phone" text="15019479320" title = "拨打电话"><u-text>' 
	html += '<u-text mode="date" text="1612959739"></u-text>' 
	html += '<u-text mode="title" text="1612959739"></u-text>' 
	html += '</title>' 
	let json = html2json(html)
	// console.log(json.child)
	json.child.map((fv, fk) => {
		if (typeof fv.child != 'undefined') {
			fv.child.map((sv, sk) => {
				console.log(sv)
				sv.attr.compId = md5(JSON.stringify(sv))
				sv.h = 30
				sv.w = 375
				sv.isResize = false
				if (typeof sv.attr != 'undefined') {
					if (typeof sv.attr.size == 'undefined') {
						sv.attr.size = 'small'
					}
				}else{
					sv.attr = {size:'small'}
				}
			})
		}
	})
	console.log(json.child)	
	return json.child
}
}
